#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

int n;
string s;
string res;

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> s;

    s = "?" + s;
    res = s;

    int fo1 = 1;
    while(s[fo1] == '0' && fo1 <= n) fo1 ++;

    if(fo1 == n + 1){
        cout << 0 << '\n';
        return 0;
    }
    int fo0 = fo1;
    while(s[fo0] == '1' && fo0 <= n) fo0 ++;

    if(fo0 == n + 1){
        cout << s.substr(1, n) << '\n';
        return 0;
    }

   // cout << "fo1: " << fo1 << " fo0: " << fo0 << '\n';


    for(int i = fo1; i < fo0; i ++){
        if(s[i] != '1') continue;

        
        string temp = s.substr(1, n - (fo0 - i));
        string s1 = s;
        for(int tail1 = s1.length(), tail2 = temp.length(); tail1 >= 1 && tail2 >= 0; tail1 --, tail2--){
            if(s1[tail1] == '1' || temp[tail2] == '1') s1[tail1] = '1';
        }

        // cout <<"s1: " << s1 << '\n';

        for(int j = 1; j <= n; j ++){
            if(res[j] > s1[j]) break;

            if(res[j] < s1[j]){
                // cout << "--------------------------" << '\n';
                // cout << "res: " << res << '\n';
                // cout << "j : " << j << " " << res[j] << " " << s1[j] << '\n';
                res = s1;
                break;
            }
        }
    }

    int hh = 1;
    while(res[hh] == '0') hh ++;


    cout << res.substr(hh, n);





    return 0;
}